<template>
  <div class="zh-wx">
    <HeaderBar></HeaderBar>
    <RouterView v-slot="{ Component }">
      <transition name="fade" mode="out-in" v-if="isKeepActive">
        <KeepAlive >
          <component :is="Component"/>
        </KeepAlive>
      </transition>
      <transition name="fade" mode="out-in" v-else>
        <component :is="Component"/>
      </transition>
    </RouterView>
  </div>
</template>
<script setup lang="ts">
  import { computed } from 'vue'
  import { useRoute } from 'vue-router'
  import HeaderBar from '@/components/headerBar.vue'

  const route = useRoute()
  const isKeepActive = computed(() => {
    return route.meta && route.meta.keepAlive?true:false
  })

</script>
<style lang="scss" scoped>
.zh-wx {
  //padding-top: 80px;
  .fade-enter-active {
    animation: moveIn 0.15s;
  }
  .fade-leave-active {
    animation: moveOut 0.15s;
  }

  @keyframes moveIn {
    0% {
      opacity: 0;
      transform: translateX(100px);
    }
    100% {
      opacity: 1;
      transform: translateX(0px);
    }
  }

  @keyframes moveOut {
    0% {
      opacity: 1;
      transform: translateX(0);
    }
    100% {
      opacity: 0;
      transform: translateX(-100px);
    }
  }
}
</style>
